package org.dreamwork.android.websocket.impls.async_http_client_1_9_40;

import com.ning.http.client.ws.DefaultWebSocketListener;
import com.ning.http.client.ws.WebSocket;
import org.dreamwork.android.websocket.IWebSocketListener;

/**
 * Created by game on 2017/3/4
 */

class AsyncHttpClientWebSocketListenerDelegate extends DefaultWebSocketListener {
    private IWebSocketListener listener;

    AsyncHttpClientWebSocketListenerDelegate (IWebSocketListener binder) {
        this.listener = binder;
    }

    @Override
    public void onOpen (WebSocket websocket) {
        listener.onOpen ();
    }

    @Override
    public void onMessage (byte[] message) {
        listener.onMessageReceived (message);
    }

    @Override
    public void onMessage (String message) {
        listener.onMessageReceived (message);
    }

    @Override
    public void onClose (WebSocket websocket) {
        listener.onClose ();
    }

    @Override
    public void onError (Throwable error) {
        listener.onError (error);
    }
}